window.addEventListener("load", function () {
	$("#reBtn").addEventListener("click", function (e) {
		let usernameValue = $("#userName").value;
		let passwordValue = $("#passWord").value;
		if (usernameValue.length < 6 || usernameValue.length > 20) {
			$("#userName").style.border = "3px solid red";
			$("#userName").nextElementSibling.textContent = "请输入6~20位字母数字";
		} else {
			$("#userName").style.border = "3px solid green";
		}

		if (passwordValue.length < 6 || passwordValue.length > 12) {
			$("#passWord").style.border = "3px solid red";
			$("#passWord").nextElementSibling.textContent = "请输入6至12位的密码";
		} else {
			$("#passWord").style.border = "3px solid green";
		}
		// 电话号码：有点问题 没成功
		if ($("#telNum").value.length !== 11) {
			$("#telNum").style.border = "3px solid red";
			$("#telNum").nextElementSibling.textContent = "手机号码必须11位";
		} else {
			$("#3telNum").style.border = "3px solid green";
		}
		e.preventDefault();
	});

	let flag = true;
	$(".checkbox").addEventListener("click", function () {
		if (flag) {
			$("#reBtn").classList.add("active");
			$("#reBtn").style.color = "#fff";
		} else if (!flag) {
			$("#reBtn").classList.remove("active");
			$("#reBtn").style.color = "#5f5f5f";
		}
		flag = !flag;
	});
	//功能二：获取验证码
	//1获取相关节点

	//2.给节点绑定点击事件，
	$("#codebtn").addEventListener("click", function () {
		console.log("111");
		// 3.点击后开启周期计时器
		let num = 60;
		let timer = window.setInterval(function () {
			//4.让节点的内容没秒减少1
			num--;
			$("#codebtn").textContent = num;
			//5.当内容为0时关闭周期定时器，并显示原文本
			if (num < 0) {
				window.clearInterval(timer);
				$("#codebtn").textContent = "获取验证码";
			}
		}, 1000);
	});
});
